package com.lntea.pdf;

public class PdfCleanup {

	public static void main(String[] args) {
		// set input and output file
		String input = "AliceInWonderland.pdf";
		String output = "AliceInWonderland_redacted.pdf";
		 
		// define a strategy
		// a Composite strategy acts as a collection of other strategies
		CompositeLocationExtractionStrategy strategy = new CompositeLocationExtractionStrategy();          
		// redact all occurences of the word 'Alice' with a pink marker
		strategy.add(new PatternLocationExtractionStrategy("Alice").setRedactionColor(Color.PINK));                                       
		// redact all occurences of 'Rabbit' and 'White Rabbit' (with some variations on case) with a gray marker
		strategy.add(new PatternLocationExtractionStrategy("((w|W)hite (r|R)abbit)|( rabbit)|(Rabbit)").setRedactionColor(Color.GRAY));   
		 
		// load the document
		PdfDocument pdf = new PdfDocument(new PdfReader(input), new PdfWriter(output));
		 
		// sweep
		PdfAutoSweep autoSweep = new PdfAutoSweep(composite);
		autoSweep.cleanUp(pdf);
		 
		// close the document
		pdf.close();
	}
}
